﻿namespace AvaloniaBlazorWebView
{
    partial class BlazorWebView
    {
        protected override async void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
        {
            base.OnAttachedToVisualTree(e);

            await CreateWebViewManager();

            if (_webviewManager is null)
                return;

            _webviewManager.Navigate(_startAddress);
        }

        protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e)
        {
            base.OnDetachedFromVisualTree(e);
            Child = null;
            _platformWebView?.Dispose();
            _platformWebView = null;
        }

    }

}

